package com.joysuch.wwyt.core.enums;

/**
 * @Author ZhangDong
 * @Date 2020/9/28 10:52
 */
public enum BaseIdCardTypes {

    INDENTIRY(0, "居民身份证"),
    SOLIDIER_ID(1, "士官证"),
    STUDENT_ID(2, "学生证"),
    DRIVE_ID(3, "驾驶证"),
    PASSPORT(4, "护照"),
    HK_MACAO_PERMIT(5, "港澳通行证");

    private Integer index;
    private String name;

    BaseIdCardTypes(Integer index, String name) {
        this.index = index;
        this.name = name;
    }

    public Integer getIndex() {
        return index;
    }

    public void setIndex(Integer index) {
        this.index = index;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static String getIdName(Integer index) {
        BaseIdCardTypes[] values = BaseIdCardTypes.values();
        for (BaseIdCardTypes value : values) {
            if (value.getIndex().equals(index)) {
                return value.name;
            }
        }
        return null;
    }

    public static Integer getIndexByName(String name) {
        if(name == null) {
            return null;
        }
        BaseIdCardTypes[] values = BaseIdCardTypes.values();
        for (BaseIdCardTypes value : values) {
            if (value.getName().equals(name)) {
                return value.index;
            }
        }
        return null;
    }

}
